/*
package com.company.project.common.utils;

import com.aliyun.opensearch.OpenSearchClient;
import com.aliyun.opensearch.SearcherClient;
import com.aliyun.opensearch.sdk.dependencies.com.google.common.collect.Lists;
import com.aliyun.opensearch.sdk.generated.OpenSearch;
import com.aliyun.opensearch.sdk.generated.commons.OpenSearchClientException;
import com.aliyun.opensearch.sdk.generated.commons.OpenSearchException;
import com.aliyun.opensearch.sdk.generated.search.Config;
import com.aliyun.opensearch.sdk.generated.search.SearchFormat;
import com.aliyun.opensearch.sdk.generated.search.SearchParams;
import com.aliyun.opensearch.sdk.generated.search.general.SearchResult;
import com.aliyun.opensearch.search.SearchParamsBuilder;
import lombok.extern.slf4j.Slf4j;

import java.nio.charset.Charset;


@Slf4j
public class OpenSearchUtils {
    private static String appName = "open_521_car";
    private static String host = "http://opensearch-cn-shenzhen.aliyuncs.com";

    public static void main(String[] args) {
        //用户识别信息
        //从环境变量读取配置的AccessKey ID和AccessKey Secret，运行代码示例前必须先配置环境变量
        String accesskey = "LTAI5t6CgaqfeTAUzCRA3qCu";
        String secret = "LjCpqtPjrpKhyx2JJSrsdA2Fm4CA8J";
        //查看文件和默认编码格式
        System.out.println(
                String.format("file.encoding: %s", System.getProperty("file.encoding"))
        );
        System.out.println(
                String.format("defaultCharset: %s", Charset.defaultCharset().name())
        );
        //创建并构造OpenSearch对象
        OpenSearch openSearch = new OpenSearch(accesskey, secret, host);
        //创建OpenSearchClient对象，并以OpenSearch对象作为构造参数
        OpenSearchClient serviceClient = new OpenSearchClient(openSearch);
        //创建SearcherClient对象，并以OpenSearchClient对象作为构造参数
        SearcherClient searcherClient = new SearcherClient(serviceClient);
        //定义Config对象，用于设定config子句参数，分页或数据返回格式，指定应用名等等
        Config config = new Config(Lists.newArrayList(appName));
        config.setStart(0);
        config.setHits(5);
        //设置返回格式为FULLJSON，目前支持返回 XML，JSON，FULLJSON 等格式
        config.setSearchFormat(SearchFormat.FULLJSON);
        // 设置搜索结果返回应用中哪些字段
        config.setFetchFields(
                Lists.newArrayList(
                        "id",
                        "title",
                        "spuid"
                )
        );
        // 注意：config子句中的rerank_size参数，在Rank类对象中设置
        //设置Kvpairs子句参数,此处为distinct子句添加uniq插件，用于reserverd=false时，total及viewtotal不准确问题
        //config.setKvpairs("duniqfield:cate_id");
        // 创建参数对象
        SearchParams searchParams = new SearchParams(config);
        // 设置查询子句，若需多个索引组合查询，需要setQuery处合并（如下示例，可以用OR拼接），否则若设置多个setQuery后面的会替换前面查询
        */
/*searchParams.setQuery("select t1.id_1,t1.spuid_1  from tt_channel_goods_spu as t1 " +
                " join tt_channel_goods_sku as t2 on t1.spuid_1 = t2.spuid");*//*

        searchParams.setQuery("default:'ES3000'");
        //添加raw_query参数(参数值需要和query查询词保持一致)
       // searchParams.setRawQuery("opensearch");
        // SearchParams的工具类，提供了更为便捷的操作
        SearchParamsBuilder paramsBuilder = SearchParamsBuilder.create(
                searchParams
        );
        */
/*//*
/ 使用SearchParamsBuilder对象添加搜索结果摘要
        paramsBuilder.addSummary("name", 50, "em", "...", 1);
        // 设置查询过滤条件
        paramsBuilder.addFilter("id>=0", "AND");*//*


        // 设置disable参数，关闭重查功能：
        //searchParams.putToCustomParam("disable", "re_search");
        try {
            // 执行返回查询结果。用户需按code和message，进行异常情况判断。code对应的错误信息查看——错误码文档。
            SearchResult searchResult = searcherClient.execute(paramsBuilder);
            String result = searchResult.getResult();
            // 输出查询结果
            log.info("查询结果："+ result);
        } catch (OpenSearchException e) {
            e.printStackTrace();
        } catch (OpenSearchClientException e) {
            e.printStackTrace();
        }
    }
}
*/
